using System;
using System.Data;
using System.Security.Cryptography;
using System.Web.Security;  


namespace Metro.Security
{
    public class Authentication
    {
        static Authentication()
        {
            
        }

        public static string CreatePasswordHash(string pwd, string salt)
        {
            string hashedPwd =""; 
            try
            {
                string saltAndPwd = String.Concat(pwd, salt);
                hashedPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(saltAndPwd, "SHA1");
            }
            catch (Exception ex)
            {
                throw ex;
            } 
            return hashedPwd;
        }

        public static string CreateSalt(int size)
        {
            string retVal = "";
            try
            {
                RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
                byte[] buff = new byte[size];
                rng.GetBytes(buff);
                retVal = Convert.ToBase64String(buff);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return retVal; 
        }
    }
}

        